import request from '@/utils/request'

export function getBasisList(type, params) {
  let url = ''
  switch (type) {
    case 'constant':
      url = 'constant'
      break
    case 'getCsgo':
      url = 'getCsgo'
      break
    default:
      break
  }
  return new Promise((resolve, reject) => {
    request({
      url,
      method: 'get',
      params
    })
      .then(res => {
        resolve(res)
      })
      // eslint-disable-next-line handle-callback-err
      .catch(error => {
        const data = {
          total: 0,
          pageItems: []
        }
        resolve(data)
      })
  })
}

export function addBasisOne(type, data) {
  let url = ''
  switch (type) {
    case '':
      url = ''
      break
    default:
      break
  }
  return new Promise((resolve, reject) => {
    request({
      url,
      method: 'post',
      data
    })
      .then(res => {
        resolve(res)
      })
      .catch(() => {
        const data = {
          total: 0,
          pageItems: []
        }
        resolve({ data })
      })
  })
}

export function updateBasisOne(type, data) {
  let url = ''
  switch (type) {
    case 'getSteamUpdate':
      url = 'getSteamUpdate'
      break
    case 'getSteamBatchUpdate':
      url = 'getSteamBatchUpdate'
      break
    case 'getSteamCheck':
      url = 'getSteamCheck'
      break
    case 'getClipUpdate':
      url = 'getClipUpdate'
      break
    case 'getClipBatchUpdate':
      url = 'getClipBatchUpdate'
      break
    case 'getClipCheck':
      url = 'getClipCheck'
      break
    case 'getClipOrderUpdate':
      url = 'getClipOrderUpdate'
      break
    case 'getClipOrderBatchUpdate':
      url = 'getClipOrderBatchUpdate'
      break
    case 'getClipOrderCheck':
      url = 'getClipOrderCheck'
      break
    default:
      break
  }
  return new Promise((resolve, reject) => {
    request({
      url,
      method: 'post',
      data
    })
      .then(res => {
        resolve(res)
      })
      .catch(() => {
        const data = {
          total: 0,
          pageItems: []
        }
        resolve({ data })
      })
  })
}

export function deleteBasisOne(type, data) {
  let url = ''
  switch (type) {
    case 'getSteamDelete':
      url = 'getSteamDelete'
      break
    case 'getClipDelete':
      url = 'getClipDelete'
      break
    case 'getClipOrderDelete':
      url = 'getClipOrderDelete'
      break
    default:
      break
  }
  return new Promise((resolve, reject) => {
    request({
      url,
      method: 'post',
      data
    })
      .then(res => {
        resolve(res)
      })
      .catch(() => {
        const data = {
          total: 0,
          pageItems: []
        }
        resolve({ data })
      })
  })
}
